<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="sec"	uri="http://www.springframework.org/security/tags"%>
<html>
	<head>
		<title><spring:message code="login.title" /></title>
		<link rel="stylesheet" type="text/css" href="/css/temporal/login-global.css" />
		<link rel="stylesheet" type="text/css" href="/css/temporal/login-marketplace.css" />
	</head>
	<body>
		<sec:authorize access="isAnonymous()">
			<div id="com_main_login">
				<div id="login_box" class="login_form">
					<h2><spring:message code="login.header" /></h2><br />
					<p id="userWarning" class="error" style="display: none">
						<spring:message code="login.nouser" />
					</p>			    
				    <form action="/login/submit" method="post">
						<div class="input_block">
					      <div class="label">
					        <label for="username"><spring:message code="login.label.username" /></label>
					      </div>
					      <div class="field">
							<input id="input_login" name="username" class="text" title="username" type="text" tabindex="1" value="<c:if test="${not empty error}"><c:out value="${SPRING_SECURITY_LAST_USERNAME}" escapeXml="false" /></c:if>" size="30" maxlength="2048" />				      	
					      </div>
					    </div>
					    <div class="input_block">
					      <div class="label">
					        <label for="password"><spring:message code="login.label.password" /><!--  <a href="https://www.storenvy.com/forgot" id="password_link">Forget your password?</a> --></label>
					      </div>
					      <div class="field">
							<input id="input_password" name="password" class="text" title="password" type="password" tabindex="2" value="" size="30" maxlength="2048" />				        
					      </div>
							<div class="clearfix"></div>
					    </div>
					    <div class="checkbox">
							<input id="remember_me" name="remember_me" tabindex="3" value="1" type="checkbox">					    
							<label for="remember_checkbox"><spring:message code="login.label.remember" /></label>					    
						 	<spring:message code="login.create" htmlEscape="false" /><br />
							<c:if test="${not empty error}">
								<p class="error"><spring:message code="login.error" /></p>
							</c:if>					      
					    </div>
					    <div id="login-links" class="group">
					      <!--<input class="login float_left" id="submit_button" src="/css/temporal/images/btn_log_in.png" tabindex="4" type="image"> -->
					      <a href="#" class="login float_left" id="submit_button" onclick="$(this).closest('form').submit()" tabindex="4"><img src="/css/temporal/images/btn_log_in.png"/></a>
					      <!--<span class="or float_left">or</span>
					      <a href="https://www.storenvy.com/join"><img alt="Btn_join_storenvy" class="float_left" id="btn_join_storenvy" src="/css/temporal/images/btn_join_storenvy.png"></a>-->
						  <!--<a href="#" onclick="$(this).closest('form').submit()"><img src="/css/temporal/images//css/temporal/images//btn_join_storenvy.png"/></a>-->				      
					    </div>
					</form>
				</div>
			</div>
		</sec:authorize>

		<script type="text/javascript">
			$(document).ready(function() {
				$("input[name='username']").blur(function() {
					var values = {};
					values['username'] = this.value;
	
					sendJson(values, '/login/validate', function(result) {
						if (result.found) {
							$('#userWarning').hide();
						} else {
							$('#userWarning').show();
						}
					});
				});
			});
		</script>
	</body>
</html>
